package com.hx.er.action.common;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import com.hx.er.action.base.ErBaseAction;
import com.hx.er.common.exception.ErException;

public class PictureAction extends ErBaseAction {

	// 序列化ID
	private static final long serialVersionUID = 2595568569561923599L;

	// 图片路径
	private String pictureFileName;

	// 图片流
	private InputStream pictureStream;

	public String init() throws ErException {
		String root = request.getServletContext().getRealPath("/");
		File pictureFile = new File(root, this.pictureFileName);

		// 循环上传的文件
		try {
			this.pictureStream = new FileInputStream(pictureFile);
		} catch (FileNotFoundException e) {
			throw new ErException(e);
		}

		return SUCCESS;
	}

	public InputStream getPictureStream() {
		return this.pictureStream;
	}

	public void setPictureStream(InputStream pictureStream) {
		this.pictureStream = pictureStream;
	}

	public String getPictureFileName() {
		return pictureFileName;
	}

	public void setPictureFileName(String pictureFileName) {
		this.pictureFileName = pictureFileName;
	}

}